Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Fix GhTokenInput not handling keyboard shortcut bug. #1707

Merged
merged 1 commit into from
Sep 21, 2020

Conversation

sainthkh
Copy link
Contributor

@sainthkh sainthkh commented Sep 15, 2020

closes TryGhost/Ghost#11786

It was because ember-power-select was stopping the propagation of the events when ctrl/cmd or meta key is down.


Explanation in more detail

GhTokenInput uses PowerSelect component of ember-power-select internally in app/components/gh-token-input/select-multiple.

When you open that component, you can find that it calls stopImmediatePropagation when ctrl/cmd or meta key is down.

  handleTriggerKeydown(e: KeyboardEvent) {
    if (this.args.onKeydown && this.args.onKeydown(this.storedAPI, e) === false) {
      e.stopImmediatePropagation();
      return;
    }
    if (e.ctrlKey || e.metaKey) {
      e.stopImmediatePropagation();
      return;
    }
    if ((e.keyCode >= 48 && e.keyCode <= 90) || isNumpadKeyEvent(e)) { // Keys 0-9, a-z or numpad keys
      (this.triggerTypingTask as unknown as Performable).perform(e);
    } else if (e.keyCode === 32) {  // Space
      this._handleKeySpace(this.storedAPI, e);
    } else {
      return this._routeKeydown(this.storedAPI, e);
    }
  }

Because of that, I had to dispatch event directly to the root of the Ghost admin app.


  • There's a clear use-case for this code change
  • Commit message has a short title & references relevant issues
  • The build will pass (run ember test from the repo root - will be core/client if working from the submodule in Ghost).

More info can be found by clicking the "guidelines for contributing" link above.

closes TryGhost/Ghost#11786

It was because ember-power-select was stopping the propagation of the events when ctrl/cmd or meta key is down.
@sainthkh sainthkh marked this pull request as ready for review September 15, 2020 04:30
@kevinansfield kevinansfield merged commit d6bca3d into TryGhost:master Sep 21, 2020
@kevinansfield
Copy link
Member

Thanks @sainthkh 🙌

kevinansfield pushed a commit that referenced this pull request Aug 3, 2022
closes TryGhost/Ghost#12294
refs #1707

- cache registered shortcuts and check KeyboardEvent before dispatching event to the root
tigefa4u pushed a commit to tigefa4u/Ghost that referenced this pull request Aug 3, 2022
closes TryGhost#12294
refs TryGhost/Admin#1707

- cache registered shortcuts and check KeyboardEvent before dispatching event to the root
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CMD+S on tags input in post triggers browser save instead of post.
2 participants